package com.moment.hello.common.annotation;

import java.lang.reflect.Method;
import java.util.HashMap;

public class GetHelloMethodAnnotation {

    HashMap<Method, HelloAnnotation> methodAnnoMap = new HashMap<>();

    public GetHelloMethodAnnotation(Object object) {
        for (Method method : object.getClass().getMethods()) {
            HelloAnnotation helloAnnotation = (HelloAnnotation) method.getAnnotation(HelloAnnotation.class);
            if (helloAnnotation != null) {
                methodAnnoMap.put(method, helloAnnotation);
            }
        }
    }

    public String getName(Method method) {
        return methodAnnoMap.containsKey(method) ? methodAnnoMap.get(method).name() : null;
    }

    public HelloAnnotation.Status getStatus(Method method) {
        return methodAnnoMap.containsKey(method) ? methodAnnoMap.get(method).status() : null;
    }
}
